package com.wuge.gulimall.product.config;

import org.omg.PortableServer.THREAD_POLICY_ID;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

@Configuration
public class ThreadConfig {
    @Bean
    public ThreadPoolExecutor getThreadPool(ThreadPoolPropertits threadPoolPropertits) {
        return new ThreadPoolExecutor(threadPoolPropertits.getCoresize(), threadPoolPropertits.getMaxsize(), threadPoolPropertits.getWaitTime(), TimeUnit.SECONDS, new ArrayBlockingQueue<>(10), Executors.defaultThreadFactory(), new ThreadPoolExecutor.AbortPolicy());
    }
}
